package com.msconfig.mvp.view.adapter;

/*
 * author: caojunhao
 * date  : 2020/8/12
 * desc  :
 */

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.geo.msconfig.R;
import com.msconfig.bean.ConfigFileDetailBean;

import java.util.ArrayList;

public class ConfigFileDetailAdapter extends BaseAdapter {
    private ArrayList<ConfigFileDetailBean> configFileDetailBeans;
    private Context mContext;

    public ConfigFileDetailAdapter(ArrayList<ConfigFileDetailBean> configFileDetailBeans, Context context){
        this.configFileDetailBeans =configFileDetailBeans;
        this.mContext =context;
    }

    @Override
    public int getCount() {
        return configFileDetailBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return configFileDetailBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView==null){
            convertView = LayoutInflater.from(mContext).inflate(R.layout.layout_configfile_detail_listview_item,parent,false);
            holder = new ViewHolder();
            holder.tvTitle = (TextView)convertView.findViewById(R.id.tv_title);
            holder.tvContent = (TextView)convertView.findViewById(R.id.tv_content);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder)convertView.getTag();
        }
        holder.tvTitle.setText(configFileDetailBeans.get(position).getTitle());
        holder.tvContent.setText(configFileDetailBeans.get(position).getContent());
        return convertView;
    }
    static class ViewHolder{
        TextView tvTitle;
        TextView tvContent;
    }
}
